// Author: wsfuyibing <682805@qq.com>
// Date: 2025-06-12

package responses

import (
	"server/app/http/models"
	"server/app/kind"
)

// UserLoginResponse
// 用户登录信息.
type UserLoginResponse struct {
	Id        int64
	UserId    kind.UserId
	Kind      kind.OauthKind
	KindText  string
	Type      kind.DeviceType
	TypeFlag  string
	TypeText  string
	Code      string
	Brand     string
	Model     string
	OsName    string
	OsVersion string
	Datetime  string
	Month     string
}

// With
// 数据绑定.
func (o *UserLoginResponse) With(m *models.UserLogins) *UserLoginResponse {
	t := m.CreatedAt.Time()

	o.Id = m.Id
	o.UserId = m.UserId
	o.Kind = m.Kind
	o.KindText = m.Kind.Text()
	o.Type = m.Type
	o.TypeFlag = m.Type.String()
	o.TypeText = m.Type.Text()
	o.Code = m.Code
	o.Brand = m.Brand
	o.Model = m.Model
	o.OsName = m.OsName
	o.OsVersion = m.OsVersion
	o.Datetime = t.Format("2006/01/02 15:04")
	o.Month = t.Format("2006-01")
	return o
}
